package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.Shops;
import com.hello.system.service.IShopsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 商家店铺信息Controller
 * 
 * @author hello
 * @date 2025-10-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/shops")
public class ShopsController extends BaseController
{
    private final IShopsService shopsService;

    /**
     * 查询商家店铺信息列表
     */
    @RequiresPermissions("system:shops:list")
    @GetMapping("/list")
    public TableDataInfo list(Shops shops)
    {
        startPage();
        List<Shops> list = shopsService.selectShopsList(shops);
        return getDataTable(list);
    }

    /**
     * 导出商家店铺信息列表
     */
    @RequiresPermissions("system:shops:export")
    @Log(title = "商家店铺信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Shops shops)
    {
        List<Shops> list = shopsService.selectShopsList(shops);
        ExcelUtil<Shops> util = new ExcelUtil<Shops>(Shops.class);
        util.exportExcel(response, list, "商家店铺信息数据");
    }

    /**
     * 获取商家店铺信息详细信息
     */
    @RequiresPermissions("system:shops:query")
    @GetMapping(value = "/{shopId}")
    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
    {
        return success(shopsService.selectShopsByShopId(shopId));
    }

    /**
     * 新增商家店铺信息
     */
    @RequiresPermissions("system:shops:add")
    @Log(title = "商家店铺信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Shops shops)
    {
        return toAjax(shopsService.insertShops(shops));
    }

    /**
     * 修改商家店铺信息
     */
    @RequiresPermissions("system:shops:edit")
    @Log(title = "商家店铺信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Shops shops)
    {
        return toAjax(shopsService.updateShops(shops));
    }

    /**
     * 删除商家店铺信息
     */
    @RequiresPermissions("system:shops:remove")
    @Log(title = "商家店铺信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopIds}")
    public AjaxResult remove(@PathVariable Long[] shopIds)
    {
        return toAjax(shopsService.deleteShopsByShopIds(shopIds));
    }
}
